package com.isdepci.project.gasEmission.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.isdepci.framework.aspectj.lang.annotation.Log;
import com.isdepci.framework.aspectj.lang.enums.BusinessType;
import com.isdepci.project.gasEmission.domain.TitleSheet;
import com.isdepci.project.gasEmission.service.ITitleSheetService;
import com.isdepci.framework.web.controller.BaseController;
import com.isdepci.framework.web.domain.AjaxResult;
import com.isdepci.common.utils.poi.ExcelUtil;
import com.isdepci.framework.web.page.TableDataInfo;

/**
 * 标题页Controller
 *
 * @author isdepci
 * @date 2023-09-01
 */
@RestController
@RequestMapping("/titleSheet/titleSheet")
public class TitleSheetController extends BaseController
{
    @Autowired
    private ITitleSheetService titleSheetService;

    /**
     * 查询标题页列表
     */
    @PreAuthorize("@ss.hasPermi('titleSheet:titleSheet:list')")
    @GetMapping("/list")
    public TableDataInfo list(TitleSheet titleSheet)
    {
        startPage();
        List<TitleSheet> list = titleSheetService.selectTitleSheetList(titleSheet);
        return getDataTable(list);
    }

    /**
     * 导出标题页列表
     */
    @PreAuthorize("@ss.hasPermi('titleSheet:titleSheet:export')")
    @Log(title = "标题页", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TitleSheet titleSheet)
    {
        List<TitleSheet> list = titleSheetService.selectTitleSheetList(titleSheet);
        ExcelUtil<TitleSheet> util = new ExcelUtil<TitleSheet>(TitleSheet.class);
        return util.exportExcel(list, "titleSheet");
    }

    /**
     * 获取标题页详细信息
     */
    @PreAuthorize("@ss.hasPermi('titleSheet:titleSheet:query')")
    @GetMapping(value = "/{infoId}")
    public AjaxResult getInfo(@PathVariable("infoId") Long infoId)
    {
        return AjaxResult.success(titleSheetService.selectTitleSheetById(infoId));
    }

    /**
     * 新增标题页
     */
    @PreAuthorize("@ss.hasPermi('titleSheet:titleSheet:add')")
    @Log(title = "标题页", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TitleSheet titleSheet)
    {
        return toAjax(titleSheetService.insertTitleSheet(titleSheet));
    }

    /**
     * 修改标题页
     */
    @PreAuthorize("@ss.hasPermi('titleSheet:titleSheet:edit')")
    @Log(title = "标题页", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TitleSheet titleSheet)
    {
        return toAjax(titleSheetService.updateTitleSheet(titleSheet));
    }

    /**
     * 删除标题页
     */
    @PreAuthorize("@ss.hasPermi('titleSheet:titleSheet:remove')")
    @Log(title = "标题页", businessType = BusinessType.DELETE)
	@DeleteMapping("/{infoIds}")
    public AjaxResult remove(@PathVariable Long[] infoIds)
    {
        return toAjax(titleSheetService.deleteTitleSheetByIds(infoIds));
    }
}
